import path from "path"
import resret from "../../commonPort/resret"
import isuser from "../../commonPort/isuser"
import {readFlie,writeFlie} from "../../../../fs_file包封装/node_modules/fs_file"
export default function registry(req,res) { //登录验证
    let {
        user, pass
    } = JSON.parse(req.buf)
    let arr = JSON.parse(readFlie(path.join(__dirname, "../json/name.json")))
    let off = isuser(user, pass, arr) === 3
    if (off) {
        arr.push({
            user,
            pass
        })
        writeFlie(path.join(__dirname, "../json/name.json"), JSON.stringify(arr))

        resret({
            res,
            text: "001"
        })
    } else {
        resret({
            res,
            text: "002"
        })
    }
    return true;

}